package com.application.validate;

import com.jfinal.core.Controller;
import com.platform.mvc.user.User;

public class ValicodeValidator extends ApiValidator {
    @Override
    protected void validate(Controller c) {
        String key = getActionKey();
        if("/api/valicode/send".equalsIgnoreCase(key)){
            int type = c.getParaToInt("type");
            String mobile = c.getPara("mobile");
            if(type == 2){
                //找回密码校验
                User user = User.dao.findByUsername(mobile);
                if (user == null) {
                    addError("regMsg", "用户不存在！");
                }
            } else if(type == 5) {
                User user = User.dao.findByUsername(mobile);
                if (user != null) {
                    addError("regMsg", "用户已存在！");
                }
            }
        }

    }

}
